package com.example.schedule;


import com.example.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 定时任务，每2个小时 获取一次
 * @author lj
 * @date 2023/5/16 19:48
 * @description
 */
@Component
@Slf4j
public class HotNewsSchedule {

    @Resource
    TestService testService;


    /**
     * 每两小时同步一次
     *
     * 2023-05-16 23:00:00
     * 2023-05-17 01:00:00
     * 2023-05-17 03:00:00
     * 2023-05-17 05:00:00
     * 2023-05-17 07:00:00
     * 2023-05-17 09:00:00
     * 2023-05-17 11:00:00
     * 2023-05-17 13:00:00
     * 2023-05-17 15:00:00
     * 2023-05-17 17:00:00
     */
    @Scheduled(cron="0/5 * * * * ?")
    public void execute(){
        testService.test();
    }
}
